home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Answers 2002 January
/
PC Answers January 2002.7z
/
PC Answers January 2002.bin
/
graphics
/
freepixl
/
_SETUP.1
/
geocorrect.pxl
< prev
next >
Wrap
Text File
|
2000-09-17
|
11KB
|
350 lines
{ Filename : geocorrect.pxl
Purpose : Demonstrate the geocorrect command
Date : January 18, 2000
Author : Stewart DIBBS, VYSOR Integration Inc
History:
Version : 4.40 RELEASE
Update :
Date :
--------------------------------------------------------------------------}
Initialize: {only one instance allowed}
UseCoordinates(PIXEL)
Title$ = "Using the GeoCorrection commands"
WinExist(Title$,Res)
If Res = 0 Then Goto One_Instance
Beep
WinSetActive(Title$,Res)
WinShow(Title$,RESTORE,Res)
End
One_Instance:
UseCaption(Title$) {change the title}
UseBackground(TRANSPARENT,0,128,192)
WinShow(Title$,NOTOPMOST,Res)
DrawBackGround
WinLocate(Title$,92,66,978,680,Res)
DirGet(SourceDir$) {used later for library function calls}
DragAcceptFile(ENABLE,AcceptFile)
AutoProgressBar(DISABLE)
InitFile$ = "*.bmp"
InfoMenu(REMOVE)
WaitInput(100)
SetMenu("&File",IGNORE,
"&New",CreatingFile,
"&Open",OpeningFile,
"&Save",SavingFile,
SEPARATOR,
"E&xit!",Terminate,
ENDPOPUP,
"&View",IGNORE,
"&ToolBar",ViewToolBar,
"&StatusBar",ViewStatusBar,
ENDPOPUP,
"&Information",IGNORE,
"&Concept",Concept,
"&Help",ShowAppHelp,
SEPARATOR,
"&About",About,
ENDPOPUP)
GoSub MakeToolbar
ChangeMenuItem("&ToolBar",CHECK,TBRes)
StatusWindow(ENABLE,BOTTOM,3,400,600,-1,0)
DrawStatusWinText(0,"Ready")
ChangeMenuItem("&StatusBar",CHECK,SBRes)
GoSub InfoMessage_0
Wait_for_Input:
WaitInput()
Terminate:
End
Concept:
MessageBox(OK,1,INFORMATION,
"This is a skeleton of a PiXCL application. You could briefly
describe your application's function here, or provide some
basic help information.",
"PiXCL Skeleton Concept",Res)
Goto Wait_for_Input
ShowAppHelp:
{An application Help file usually has the same name as the application.}
Winhelp("geocorrect.hlp",CONTENTS,"")
Goto Wait_for_Input
About:
AboutUser("Using the GeoCorrection commands", { or substitute Title$}
"Two lines of text goes here e.g. Application function.",
"Four Lines of additional information goes here, perhaps contact information and Web addresses")
Goto Wait_for_Input
ViewToolBar:
GetMenuStatus("&ToolBar",CHECKED,Res)
If Res = 0
GoSub MakeToolbar
ChangeMenuItem("&ToolBar",CHECK,Res)
Else
Toolbar()
ChangeMenuItem("&ToolBar",UNCHECK,Res)
Endif
Goto Wait_for_Input
ViewStatusBar:
GetMenuStatus("&StatusBar",CHECKED, Res)
If Res = 0
StatusWindow(ENABLE,BOTTOM,3,400,200,-1,0)
DrawStatusWinText(0,"Ready")
ChangeMenuItem("&StatusBar",CHECK,Res)
Else
StatusWindow(DISABLE,BOTTOM,3,400,200,-1,0)
ChangeMenuItem("&StatusBar",UNCHECK,Res)
Endif
Goto Wait_for_Input
CreatingFile:
WaitInput(1)
{TODO: add file handling here}
MessageBox(OK,1,INFORMATION,"No operations coded for this button.",
"Creating File",Res)
Goto Wait_for_Input
OpeningFile:
WaitInput(1)
DrawBackGround
SetMouse()
SetRightMouse()
Histogram()
WaitInput(1)
If ImageFile$ <> "" Then FreeBitMap(ImageFile$)
FileGet(Filter$, InitFile$, "",
"Select an image to load",CHANGEDIR,ImageFile$)
If ImageFile$ = "" Then Goto Wait_for_Input
ProcessImage:
If DFServer <> 1
FileExtension(ImageFile$,Ext$,Res)
InitFile$ = "*." + Ext$
Ext$ = Ext$ + " Image File Format Read"
GetBitMapDim(ImageFile$,Lines,Pixels,Bits)
DrawBackGround
DrawShadowText(25,0,Ext$,255,255,255,1)
DrawShadowText(560,30,"Lines",0,0,0,1) DrawShadowNumber(660,30,Lines,0,0,0,1)
DrawShadowText(560,50,"Pixels",0,0,0,1) DrawShadowNumber(660,50,Pixels,0,0,0,1)
DrawShadowText(560,70,"Bits",0,0,0,1) DrawShadowNumber(660,70,Bits,0,0,0,1)
If Bits <> 0
sx1 = 47 sy1 =65
sx2 = 53 + Pixels sy2 = 71 + Lines
DrawEdgeRectangle(sx1,sy1,sx2,sy2,SUNKENEDGE,ADJUST,RECT)
DrawBitmap(50,68,ImageFile$)
DrawSizedBitmap(580,250,830,453,ImageFile$)
DrawShadowText(590,455,"Original image thumbnail",0,0,0,1)
Endif
Else
DropFileServer(ENABLE,ImageFile$)
WinGetClientRect("",cx1,cy1,cx2,cy2)
SetMouse(cx1,cy1,cx2,cy2,EndDFS,n,n)
Endif
ChangeToolbarBtn("",7,ENABLED,Res)
ChangeToolbarBtn("",8,ENABLED,Res)
ChangeToolbarBtn("",9,ENABLED,Res)
Goto Wait_for_Input
SavingFile:
WaitInput(1)
{TODO: add file handling here}
MessageBox(OK,1,INFORMATION,
"The images loaded into the PiXCL image list are still in memory, and can be saved using the
SaveBitmap command.",
"Saving geometrically corrected files",Res)
Goto Wait_for_Input
PrintingFile:
WaitInput(1)
{TODO: add file handling here}
MessageBox(OK,1,INFORMATION,"No operations coded for this button.",
"Printing File",Res)
Goto Wait_for_Input
AcceptFile:
GetDragList(FileList$)
{TODO: add file list handling here, or delete this whole label handler}
Goto Wait_for_Input
Reporter:
rx -= 50
ry -= 68
GoSub ConvertCoords
Goto Wait_for_Input
ConvertCoords: {subroutine}
Str(rx,rx$)
Str(ry,ry$)
Msg$ = "image_X = " + rx$
DrawStatusWinText(1,Msg$)
Msg$ = "image_Y = " + ry$
DrawStatusWinText(2,Msg$)
Return
GeoCorrectionNN:
Rmode = 1
GetBackground(R,G,B)
UseBrush(SOLID,R,G,B) UsePen(NULL,1,0,0,0)
DrawRectangle(610,200,830,220)
UseFont("Arial",0,19,BOLD,NOITALIC,NOUNDERLINE,255,255,255)
DrawShadowText(610,200,"Nearest Neighbour Mode",0,0,0,1)
Goto GeoCorrection
GeoCorrectionBL:
Rmode = 2
GetBackground(R,G,B)
UseBrush(SOLID,R,G,B) UsePen(NULL,1,0,0,0)
DrawRectangle(610,200,830,220)
UseFont("Arial",0,19,BOLD,NOITALIC,NOUNDERLINE,255,255,255)
DrawShadowText(610,200,"Bilinear Interpolation Mode",0,0,0,1)
Goto GeoCorrection
GeoCorrectionBC:
Rmode = 3
GetBackground(R,G,B)
UseBrush(SOLID,R,G,B) UsePen(NULL,1,0,0,0)
DrawRectangle(610,200,830,220)
UseFont("Arial",0,19,BOLD,NOITALIC,NOUNDERLINE,255,255,255)
DrawShadowText(610,200,"Bicubic Convolution Mode",0,0,0,1)
GeoCorrection:
Msg$ = "No image has been loaded."
If ImageFile$ = "" Then MessageBox(OK,1,EXCLAMATION,Msg$,"Unable to do GeoCorrect process",Res) Goto Wait_for_Input
xx2 = sx2 - 2
yy2 = sy2 - 2
WinGetClientRect("",cx1,cy1,cx2,cy2)
UsePen(SOLID,1,255,0,0)
UseBrush(NULL,0,0,0)
DrawStatusWinText(0,"Click bottom right point #1")
SetMouse(cx1,cy1,cx2,cy2,GeoPt2,x1,y1)
SetRightMouse(0,0,540,454,Reporter,rx,ry)
WaitInput()
GeoPt2:
DrawPoint(x1,y1,CIRCLE)
x1 -= 50 y1 -= 68 y1 = Lines - y1
rx = x1 ry = y1
GoSub ConvertCoords
DrawStatusWinText(0,"Click bottom left point #2")
SetMouse(cx1,cy1,cx2,cy2,GeoPt3,x2,y2)
WaitInput()
GeoPt3:
DrawPoint(x2,y2,CIRCLE)
x2 -= 50 y2 -= 68 y2 = Lines - y2
rx = x2 ry = y2
GoSub ConvertCoords
DrawStatusWinText(0,"Click top left point #3")
SetMouse(cx1,cy1,cx2,cy2,GeoPt4,x3,y3)
WaitInput()
GeoPt4:
DrawPoint(x3,y3,CIRCLE)
x3 -= 50 y3 -= 68 y3 = Lines - y3
rx = x3 ry = y3
GoSub ConvertCoords
DrawStatusWinText(0,"Click top right point #4")
SetMouse(cx1,cy1,cx2,cy2,GeoDone,x4,y4)
WaitInput()
GeoDone:
SetMouse()
DrawPoint(x4,y4,CIRCLE)
x4 -= 50 y4 -= 68 y4 = Lines - y4
rx = x4 ry = y4
GoSub ConvertCoords
DrawStatusWinText(0,"Correcting image ...")
UseCursor(WAIT)
If Rmode = 3 Then GeoCorrectImage(x1,y1,x2,y2,x3,y3,x4,y4,BICUBIC,Res)
If Rmode = 2 Then GeoCorrectImage(x1,y1,x2,y2,x3,y3,x4,y4,BILINEAR,Res)
If Rmode = 1 Then GeoCorrectImage(x1,y1,x2,y2,x3,y3,x4,y4,NEAREST,Res)
UseCursor(ARROW)
If Res <> 0
FlipImage(VERT,Res)
DrawBitmap(50,68,ImageFile$)
Save$ = SourceDir$ + "\transformedimage.bmp"
SaveBitmap(Save$,Res)
Else
MessageBox(OK,1,EXCLAMATION, "Geo Correct operation Failed","App Message",Res)
Endif
DrawStatusWinText(0,"Ready")
DrawStatusWinText(1,"")
DrawStatusWinText(2,"")
WaitInput(1200)
GoSub InfoMessage_1
Goto Wait_for_Input
{--- Style Suggestion: place all subroutines at the end of the script.}
MakeToolbar: {subroutine}
Toolbar(RAISED, PXL_SMALL,
NULL, NULL, SEPARATOR, "", Wait_for_Input,
PXL_NEW, ENABLED, STD, "FileNew", CreatingFile,
PXL_OPEN, ENABLED, STD, "FileOpen", OpeningFile,
PXL_SAVE, ENABLED, STD, "FileSave", SavingFile,
PXL_PRINT, ENABLED, STD,"PrintFile", PrintingFile,
NULL, NULL, SEPARATOR, "", Wait_for_Input,
HELPER_1, DISABLED, STD,"GeoCorrect with Nearest Neighbour", GeoCorrectionNN,
HELPER_2, DISABLED, STD,"GeoCorrect with Bilinear Interpolation", GeoCorrectionBL,
HELPER_3, DISABLED, STD,"GeoCorrect with Bicubic Convolution", GeoCorrectionBC,
NULL, NULL, SEPARATOR, "", Wait_for_Input,
HELPINFO, ENABLED, STD,"Show Help",ShowAppHelp)
Return
InfoMessage_0:
UseFont("Arial",0,37,BOLD,NOITALIC,NOUNDERLINE,255,255,255)
DrawShadowText(35,60,"Geometric Correction Commands in PiXCL 4.4",0,0,0,2)
UseFont("Arial",0,19,BOLD,NOITALIC,NOUNDERLINE,255,255,255)
DrawShadowTextExt(60,100,750,600,
"Any bitmap image loaded into the PIXCL image list can be distorted geometrically using the set of commands including
GeoCorrectImage - transform the image using 4 ''corner'' points
GeoTranslateImage - translate the image relative to a corner point
RotateImage - rotate about the center pixel by an arbitrary degree
RotateImageExt - rotate the image about a selected point
ResampleImage - change the dimensions of the image
All these commands use one of three possible pixel resampling methods:
NEAREST NEIGHBOUR - the fastest, but with limitations to the acuracy of pixel values;
BILINEAR - slower, but provides better radiometric results;
BICUBIC- slowest, but gives the best results for the interpolated pixel values.
To continue, open one of the sample images e.g. BRSFC754.BMP",
LEFT, 0,0,0,1)
UseFont("MS Sans Serif",0,19,NOBOLD,NOITALIC,NOUNDERLINE,255,0,0)
Return
InfoMessage_1:
MessageBox(OK,1,INFORMATION,
"The four points you selected, either inside and/or outside the image, become the new
corner points for the corrected image. Hence, if a selected point is inside the image,
that point (relative to the current corner) becomes the new corner.
Conversely, a point OUTSIDE the image becomes the new adjacent corner, warping all the
pixel values and positions accordingly.
Note that is all cases, the image dimensions are unchanged. Only the relative position of the
pixels within the image are changed. It is possible to resample so that there are unpopulated
regions, which get set to black, and other regions that no longer fall within the boundaries
of the image.",
"What's happened here ?",Res)
Return